
#include "board.h" 


#include <rthw.h>
#include <rtthread.h>


#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
#define RT_HEAP_SIZE 1024

static uint32_t rt_heap[RT_HEAP_SIZE];
RT_WEAK void *rt_heap_begin_get(void)
{
    return rt_heap;
}

RT_WEAK void *rt_heap_end_get(void)
{
    return rt_heap + RT_HEAP_SIZE;
}
#endif


void rt_hw_board_init()
{
    /* SysTick 初始化 */
    SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND );	
    
		/* 硬件 BSP 初始化统统放在这里，比如 LED，串口，LCD 等 */ 
		LED_Init();
		KEY_Init();
		ILI9341_Init();
		LCD_SetColors(BLACK,WHITE);//设置白底黑字
		LCD_SetFont(&Font8x16);//设置字体大小
		ILI9341_Clear(0,0,LCD_X_LENGTH,LCD_Y_LENGTH);//清屏
		
		USART_Config();
	
	
		/* 调用组件初始化函数 (use INIT_BOARD_EXPORT()) */
#ifdef RT_USING_COMPONENTS_INIT
    rt_components_board_init();
#endif
    
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
	rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
    
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
    rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
#endif
}

/**
	* @brief SysTick 中断服务函数
  */
void SysTick_Handler(void)
{
  
    rt_interrupt_enter();

    rt_tick_increase();

    rt_interrupt_leave();
}
